package com.fasc.open.api.client;

import com.fasc.open.api.bean.base.BaseRes;
import com.fasc.open.api.bean.req.user.*;
import com.fasc.open.api.bean.res.common.EUrlRes;
import com.fasc.open.api.bean.res.user.AddOpenUserRes;
import com.fasc.open.api.bean.res.user.UserIdentityInfoRes;
import com.fasc.open.api.bean.res.user.UserRes;
import com.fasc.open.api.constants.OpenApiUrlConstants;
import com.fasc.open.api.exception.ApiException;

/**
 * @author Fadada
 * 2021/10/16 16:47:06
 */
public class UserClient {
    private OpenApiClient openApiClient;

    public UserClient(OpenApiClient openApiClient) {
        this.openApiClient = openApiClient;
    }

    public BaseRes<AddOpenUserRes> add(AddUserReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_ADD, AddOpenUserRes.class);
    }

    public BaseRes<Void> update(UpdateUserReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_UPDATE, Void.class);
    }

    public BaseRes<Void> delete(DeleteUserReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_DELETE, Void.class);
    }

    public BaseRes<Void> disable(DisableUserReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_DISABLE, Void.class);
    }

    public BaseRes<Void> enable(EnableUserReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_ENABLE, Void.class);
    }

    public BaseRes<EUrlRes> getAuthUrl(GetUserAuthUrlReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_GET_AUTH_URL, EUrlRes.class);
    }

    public BaseRes<UserRes> get(GetUserReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_GET, UserRes.class);
    }

    public BaseRes<UserIdentityInfoRes> getIdentityInfo(GetUserIdentityInfoReq req) throws ApiException {
        return openApiClient.invokeApi(req, OpenApiUrlConstants.USER_GET_IDENTITY_INFO, UserIdentityInfoRes.class);
    }

}
